package com.net.wanjian.networkhospitalmanager.adapter.base;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

/**
 * Description:
 * Created by lidongcai on 2017/4/23.
 * Email:  lidongcaiocc@163.com
 */

public class BaseViewPagerAdapter extends FragmentPagerAdapter {

    private Fragment[] fragments;
    private String[] titles;

    public BaseViewPagerAdapter(FragmentManager fm, Fragment[] fragments) {
        this(fm,fragments,null);
    }

    public BaseViewPagerAdapter(FragmentManager fm, Fragment[] fragments, String[] titles) {
        super(fm);
        this.fragments = fragments;
        this.titles = titles;
    }

    @Override
    public Fragment getItem(int position) {
        return fragments[position];
    }

    @Override
    public int getCount() {
        return fragments.length;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        if (null == titles){
            return super.getPageTitle(position);
        }else {
            return titles[position];
        }
    }
}
